<?php

function login($user, $senha, $connect){
	$usuario = null;
	$sql = "SELECT ID, USERNAME, PASSWORD, PERFIL_ID FROM USUARIO WHERE USERNAME = '".$user."' AND PASSWORD = '".$senha."'";
	$query = pg_query($connect, $sql);
	$row = 0;
	while ($data = @pg_fetch_object($query, $row)) {
		$usuario = new Usuario();
		$usuario->id = $data->id;
		$usuario->username = $data->username;
		$usuario->idPerfil = $data->perfil_id;
		$row ++;
	}
	pg_free_result($query);
	return $usuario;
}

?>
